package com.goodmean.student;

import com.goodmean.common.User;
import com.goodmean.common.model.Student;
import com.jfinal.core.Controller;

public class StudentController extends Controller {

    private StudentService service = StudentService.me;

    public void index() {
        render("student.html");
    }

    /**
     * 查询学生信息
     */
    public void findByid() {
        User user = getSessionAttr("user");
        setAttr("studentM", service.findByid(user.getId()));
        render("student.html");
    }

    //学生查询成绩
    public void findGrade() {
        User user = getSessionAttr("user");
        setAttr("grade", service.findGrade(user.getId()));
        render("teacher_course.html");
    }

    /**
     * 保存修改信息
     */
    public void saveM() {
        User user = getSessionAttr("user");
        Student student = getModel(Student.class, "");
        student.setStudentId(user.getId());
        boolean b = service.me.saveM(student);
        if (b) {
            findByid();
        } else {
            render("error.html");
        }
    }

    /**
     * 搜索课程表
     */
    public void selectCourse() {
        User user = getSessionAttr("user");
        setAttr("course", service.me.selectCourse(user.getId()));
        render("course.html");

    }

}
